package com.boc.address.model;

import com.boc.address.contract.AddAddressContract;
import com.boc.address.http.AddressApi;

import demo.bocweb.com.sdk.baseApi.AppUrl;
import demo.bocweb.com.sdk.apiHelper.RetrofitCreateHelper;
import demo.bocweb.com.sdk.apiHelper.RxHelper;
import demo.bocweb.com.sdk.base.BaseModel;
import demo.bocweb.com.sdk.base.bean.BaseBean;
import demo.bocweb.com.sdk.baseApi.BaseApi;
import demo.bocweb.com.sdk.baseApi.DistrictBean;
import io.reactivex.Observable;
import okhttp3.RequestBody;

/**
 * Created by zhelun on 2018/2/2.
 */

public class AddAddressModel extends BaseModel implements AddAddressContract.IAddAddressModel {
    public static AddAddressModel newInstance() {
        return new AddAddressModel();
    }

    @Override
    public Observable<BaseBean> addAddress(RequestBody request) {
        return RetrofitCreateHelper.createApi(AddressApi.class, AppUrl.BASE_URL)
                .addAddress(request)
                .compose(RxHelper.<BaseBean>rxSchedulerHelper());
    }

    @Override
    public Observable<BaseBean<DistrictBean>> getDistrictBean() {
        return RetrofitCreateHelper.createApi(BaseApi.class, AppUrl.BASE_URL)
                .getDistrictBean()
                .compose(RxHelper.<BaseBean<DistrictBean>>rxSchedulerHelper());
    }
}
